<!DOCTYPE html>

<head>
    <title>商品品牌搜索页面</title>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/product/product_search.css')}}">
    <link rel="stylesheet" href="{{mix('/css/web/product/product_allist.css')}}">
</head>
<body>
@include('web.layout.header_proscenium')
@include('web.layout.main_header')
<div class="search-list-wrap w1200 fade out">
    <div class="crumbs f-cb">
        <div class='onset'>
                <span class="fl">
                    <a href="/">首页</a> &gt;  所有商品 @if($search_params['product_name'])&gt;  已选条件：<span class="gray">所有与“<span class="blue">{{$search_params['product_name']}}</span>”相关的宝贝</span>@endif
                </span>
            <div class="hasChoose"></div>
            <?php if(isset($page['total'])){?>
            <span class="fr">总共找到<span class="blue" id="total"> {{$page['total']}}</span>条相关产品</span>
            <?php }?>
            <span id="note">&nbsp; </span>
        </div>
    </div>
    <div class="pro-type">
        <table width="100%">
            <tbody>
            <tr>
                <td class="tt" width="150">
                    <span>商品品牌：</span>
                </td>
                <td class="lis">
                    <div class="right">
                        @if(isset($brands) && count($brands)>10)
                        <div class="more" style="">更多</div>
                        <div class="stop" style="display: none;">收起</div>
                        @endif
                           <a data-id="0" class="brand" href="/product/search?product_name=@if($search_params['product_name']){{$search_params['product_name']}}@endif" rel="nofollow">全部</a>
                               @if(!empty($brands))
                                @foreach($brands as $k=> $b)
                                @if($k>8)
                                <div class="pp_hide">
                                @endif
                        <a rel="nofollow" href="javascript:;" class="gray_background product_brand @if(isset($search_params['brand_id']) && $b['id'] ==$search_params['brand_id'] ) cur @endif" brand-id="{{$b['id']}}" data-name="{{$b['name']}}">
                            <img src="{{$b['logo']}}">
                            <div class="name" style="bottom: -47px;">{{$b['name']}}</div>
                        </a>
                            @if($k>8)
                                </div>
                                @endif
                        @endforeach
                            @endif
                        <input type="hidden" name="brands">
                    </div>
                </td>
            </tr>
            <tr>
                <td class="tt">
                    <span>相关类目：</span>
                </td>
                <td style="border-bottom:0;">
                    <div class="link">
                        @if(!empty($cates))
                                @foreach($cates as $k=>$v)
                             <a rel="nofollow" href="javascript:;"  data-name="{{$v['name']}}" class="product_categories @if( isset($search_params['third_cat']) && $search_params['third_cat']==$v['id']) cur @endif"  pid="{{$v['pid']}}" first_id="{{$v['first_id']}}" level-type="{{$v['level_type']}}" category-id="{{$v['id']}}">{{$v['name']}}</a>
                           @endforeach
                            @endif
                        <input type="hidden" name="ctype">
                    </div>
                </td>
            </tr>
            <input type="hidden" name="order" value="1">
            </tbody>
        </table>

    </div>

    <span class="check_newtitle1">高级选项：</span>

    <div class="js-attribute">
        <ul class="check_new " style="margin-top: 0;">
        @if($pattrs)
         <?php $item=0;?>
        @foreach($pattrs as $k=>$p)
        <?php $item++;?>
             <li style="margin-bottom: 3px;margin-left: 24px;">
                <span class="name">{{$p[$k]}}
                    <span class="selectxia shousuo checkxia"></span>
                </span>
                <div class="selectnewtan " style="display: none;">
                    <img class="alllist_gbi" src="http://www.ejing365.com/img/product/guanbi.png">
                    @if($p['val'])
                    @foreach($p['val']  as $pk=>$pv)
                        <a data-hidden="0" class="attribute product_attrs" data-id="{{$pk}}" data-higher-id="{{$k}}" data-intro="{{$p[$k]}}" href="javascript:;" rel="nofollow">{{$pv}}</a>
                        @endforeach
                     @endif
                </div>
            </li>
             <?php if($item>7){break;}?>
           @endforeach
            @endif
             <li class="more_li" @if( (isset($item) && $item <9 ) || !isset($item)) style="display:none;" @endif>
                <span class="name"  >更多选项
                    <span class="selectxia shousuo checkxia"></span>
                </span>
                <div class="selectnewtan01 " style="display: none;">
                    <img class="alllist_gbi" src="http://www.ejing365.com/img/product/guanbi.png">
                    <div class="morelei">
                      <?php $ii=0;?>
                                @foreach($pattrs as $k=>$p)
                                 <?php $ii++;?>
                                 @if($ii>8)
                        <div class="left">
                            <a href="">{{$p[$k]}}</a>
                        </div>
                        <div class="right">
                           @if($p['val'])
                    @foreach($p['val']  as $pk=>$pv)
                            <a daa-hidden="0" class="attribute product_attrs"  href="javascript:;" rel="nofollow">{{$pv}}</a>  
                                   @endforeach
                     @endif    
                        </div>
                        @endif
                         @endforeach
                    </div>
                </div>
            </li>  
        </ul>
    </div>

    <div class="screen f-cb">

        <a data-id="1" old-order-id ="0" class="vs sort_order on" href="javascript:;" rel="nofollow">综合</a>
        <a data-id="4" old-order-id="" class="vs sort_order" href="javascript:;" rel="nofollow">价格</a>
        <div class="fl screen-form">
            <div class="fl val-inp">
                <span class="fl sym">￥</span>
                <input class="tex fl" type="text" name="sprice" id="sprice" value="">
            </div>
            <span class="fl to">-</span>
            <div class="fl val-inp ">
                <span class="fl sym">￥</span>
                <input class="tex fl" type="text" name="eprice" id="eprice" value="">
            </div>
            <input type="submit" class="fl sub-btn ti-jbt" value="确定">
        </div>
    </div>
    <div class="list vessel fade">
          <ul class="ptpd ovh" style="min-height: 500px">
          @if(!empty($list))
                                @foreach($list as $k=>$v)
            <li>
                  <a target="_blank" title="" href="/product/info/{{$v['product_id']}}/{{$v['id']}}">
                        <img src="{{$v['product']['cover_image']}}" alt="">
                    </a>
                    <a target="_blank" title="" href="/product/info/{{$v['product_id']}}/{{$v['id']}}" class="txt-css">{{$v['product']['name']}}</a>
                <div class="cost">
                    ￥{{$v['price']}}
                        <span class="fr">￥{{$v['sale_price']}}</span>
                      <div class="goods_bottom">
                            <a class="fl purchase add-car" target="_blank" href="/product/info/{{$v['product_id']}}/{{$v['id']}}" data-pid="{{$v['product_id']}}" data-sku_id="{{$v['id']}}" data-shop_id="{{$v['product']['shop_id']}}">加入进货单</a>
                            <div class="fr follow" data-id="{{$v['id']}}" data-pid="{{$v['product_id']}}" data-sku_id="{{$v['id']}}" data-shop_id="{{$v['product']['shop_id']}}">
                                <?php if( in_array($v['id'],$check)){?> <img  class="follow_img" src="{{asset('/img/web/product/follow.jpg')}}">
                                <font   class="gzth">已关注</font><?php }else{?>
                                <img class="no_follow_img"  id="nofimg_{{$v['id']}}"  src="{{asset('/img/web/product/no_follow.jpg')}}">
                                <img  style="display: none;" class="follow_img" id="fimg_{{$v['id']}}"  src="{{asset('/img/web/product/follow.jpg')}}">
                                <font class="gzth atten" id="atten_{{$v['id']}}" >关注</font>
                                <?php }?>
                            </div>
                        </div>
                    </div>
            </li>
             @endforeach
                            @endif
        </ul>

        <div class="page">
             @include('web.common.paginate', ['page' => $page])

            </div>
        </div>
    </div>
@include('web.layout.footer')
    <script type="text/javascript">


    var jud = '{{ Session::get("user_id")}}';
    var new_product_data =<?php echo !empty($search_params)?json_encode($search_params):'{}'?>;;
    //关注商品
    $(".follow").click(function () {
        if (jud == '' || jud == '0') {
            layer.confirm('请先登录后再关注商品，点击【确认】跳转到登录页面', {
                title: '温馨提示',
                btn: ['确认', '取消'] //可以无限个按钮
            }, function (index) {
               window.location.href = AJAX_URL + '/user/login';
            }, function (index, layero) {
                layer.close(index);
            });
            return false;

        } else {

            if ($(this).html().indexOf('已关注')>=0){
                layer.alert('您已成功关注该商品');
            }else {
                var pid =  $(this).attr("data-pid");
                var sku_id = $(this).attr("data-sku_id");
                var shop_id =  $(this).attr("data-shop_id");

                var token = "{{csrf_token()}}";
                $.ajax({
                    url: '/product/collection',
                    type: 'GET',
                    dataType: 'json',
                    data: {'product_id': pid, '_token': token, 'type': 'product', 'sku_id': sku_id, 'shop_id': shop_id},
                    success: function (data) {
                        if (data.code == 0) {
                            layer.alert('已成功关注该商品');
                            $('#atten_'+sku_id).html('已关注');
                            $('#nofimg_'+sku_id).hide();
                            $('#fimg_'+sku_id).show();
                        } else {
                            layer.alert('商品关注失败');
                        }
                    }

                })
            }
        }
    });
    //关注商品结束



    // 排序
    $(".sort_order").on('click', function(event) {
        event.preventDefault();
        /* Act on the event */
        var order = $(this).attr('data-id');
        var old_order = $(this).attr('old-order-id');
        if(5==old_order){
            order = 6;
        }
        if(6==old_order){
            order = 5;
        }

        new_product_data.order = order;
        _ajxa_list();
    });
    //高级选项删除
    $(".pro .icon-btn-x").click(function(event) {
        /* Act on the event */
        var key = $(this).attr('key-id');
        new_product_data.attrs_data[key] ={};
        _ajxa_list();
        // new_product_data.attrs_data.remove(key);
        // console.log(new_product_data);
    });

    $('.product_brand').hover(function () {
        $(this).find('.name').stop().animate({bottom: '0'})
    }, function () {
        $(this).find('.name').stop().animate({bottom: '-47px'})
    });

    //品牌
    $(".product_brand").click(function(event) {
        /* Act on the event */
        var brand_id = $(this).attr('brand-id');
        var brand_name = $(this).find('div.name').text();
        //new_product_data.brand_data={'id':brand_id,'name':brand_name}
        new_product_data.brand_id=brand_id;
        _ajxa_list();
        // console.log(new_product_data);
    });
    //分类
    $(".product_categories").click(function(event) {
        /* Act on the event */
        var pid = $(this).attr('pid');
        var first_id = $(this).attr('first_id');
        var category_ids = $(this).attr('category-id');
        var category_name = $(this).text();
        if(pid ==first_id){
            category_id = category_ids;
            new_product_data.categories_data={};
        }else{
            new_product_data.categories_data={'id':category_ids,'name':category_name};
        }

        _ajxa_list();
    });
    //高级选项
    $(".product_attrs").click(function(event) {
        /* Act on the event */
       // var attrs_id = $(this).attr('attrs-id');
       // var key = $(this).attr('key-id');
       // var item_id = $(this).attr('item-id');
      //  var key_name = $(this).attr('key-name');
        var attrs_name = $(this).text();
        if(!new_product_data.attrs_data || new_product_data.attrs_data.length<=0){

            new_product_data.attrs_data={};
        }
        //new_product_data.attrs_data[key] ={'item_id':item_id,'id':attrs_id,'name':attrs_name,'key_name':key_name};
        //new_product_data.attrs_data = key+":"+key_name+","+item_id+":"+attrs_name ;
        new_product_data.attrs_data =  attrs_name ;
        _ajxa_list();
    });
    function _ajxa_list() {
        location.href = '/product/search?'+ $.param(new_product_data);
    }


    //关注商品
    var jud = '{{ Session::get("user_id")}}';



    </script>
    <script type="text/javascript">
    $(function(){
        var index = 0 ;

            $('.more').click(function () {
                $('.pp_hide').show();
                $('.more').hide();
                $('.stop').show();
            });
            $('.stop').click(function () {
                $('.pp_hide').hide();
                $('.stop').hide();
                $('.more').show();
            });

            $('.mo-d').click(function () {
                if ($(this).hasClass('cur')) {
                    $('.check-c li').slice(2).addClass('yc-ys');
                    $('.mo-d').text('展开选项');
                    $('.check-c li:eq(1)').css({"borderBottom": "none"});
                    $(this).removeClass('cur');
                } else {
                    $('.check-c li').slice(2).removeClass('yc-ys');
                    $(this).text('收起选项');
                    $('.check-c li:eq(1)').css({"borderBottom": "1px solid #D7D7D7"});
                    $(this).addClass('cur');
                }
            });

            $('.chk li').click(function () {      //|| $(this).index() == $('.chk li:last').index()
                $(this).addClass('bj-hr ad-bk').siblings('li').removeClass('bj-hr ad-bk');
                if ($(this).index() == 0) {
                    $(this).css({"borderLeft": "none"});
                } else if ($(this).index() == $('.chk li:last').index()) {
                    $(this).css({"borderRight": "none"});
                } else if ($(this).index() == 1) {
                    $('.fir-wd').css({"borderRight": "none"});
                }
            });

            $('.fir-wd ~ li').css({"width": 74});

            $('.ptpd li').eq(4).css({"marginRight": 0});
            $('.ptpd li').eq(9).css({"marginRight": 0});
            $('.ptpd li').eq(14).css({"marginRight": 0});
            $('.ptpd li').eq(19).css({"marginRight": 0});


            //清除评价下边框
            $('.store li:last').css({"borderBottom": "none"});

            //为面包屑添加class
            // $(".crumbs a").slice(4).addClass('list');

            //给属性的 全部 选项  添加url;
            $(".allCheck").each(function (k, v) {
                //添加焦点
                var i = 0;
                var parent = $(this).siblings();
                parent.each(function (k2, v2) {
                    if ($(this).hasClass('cur')) {
                        i = 1;
                    }
                })
                //alert(i);
                if (i == 0) {
                    $(this).addClass('cur');
                }
                //添加url
                var id = $(this).data('id');
                var url = $('#atNum-' + id).attr('href');
                $(this).attr('href', url);

            });

            $('.magnifier').keydown(function(e){
                if(e.keyCode==13){

                }
            });

              //价格搜索
            $('.ti-jbt').click(function () {
                var priceUrl = '/product/search?';
                var priceUrl = priceUrl.replace(/&amp;/g,'&');
                var sprice = $("[name='sprice']").val();
                var eprice = $("[name='eprice']").val();
                var priceUrl = priceUrl + '&sale_price[start]=' + sprice + '&sale_price[end]=' + eprice;
                if (sprice && eprice) {
                    if (isNaN(sprice) || isNaN(eprice)) {
                        layer.alert('数据格式不正确', {icon: 2});
                    } else {
                        window.location.href = priceUrl;
                    }
                } else {
                    layer.alert('请填写正确的价格范围', {icon: 2});
                }
            })
            /* 面包屑显示 已选中条件 */
            function addCateNotice() {
                var curlist = $('.cur');
                var text = delmit ='';
                $.each(curlist,function (k,v) {
                    if (text!=''){
                        delmit = ' > ';
                    }
                    text +=  delmit+$(v).attr('data-name');
                });
                $('#note').append(text);
            }

            addCateNotice();
    })
</script>
<script type="text/javascript">
    $(function(){
        $(".check_new li").mouseover(function(){
            $(this).find(".selectnewtan").show();
            $(".selectnewtan01").hide();
            $(this).siblings().find(".selectnewtan").hide();
            var index=$(this).index();
            $(".check_new li").eq(0).find(".selectnewtan").css("left","0px");
            // $(this).find(".name").val()
            $(".selectnewtan,.selectnewtan01 ").mouseout(function(){
                $(this).hide();

            })
         })
        $(".check_new li,.selectnewtan01 a").mouseout(function(){
            $(".selectnewtan, .selectnewtan01").hide();
        })
        $(".selectnewtan a,.selectnewtan01 a").click(function(){
            $(".selectnewtan").hide();
            // console.log($(this).text());
            // $(this).parents(".leival").find(".name").text($(this).text());

        })
        $(".check_new li.more_li").mouseover(function(){
            $(".selectnewtan").hide();
            $(this).find(".selectnewtan01").show();
        })
        $(".alllist_gbi").click(function(){
            $(".selectnewtan, .selectnewtan01").hide();
        })
    })
</script>


</body>
</html>